package com.test.alibrary;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.test.aninterface.IPrint;
import com.test.aninterface.spiFactory;
import com.test.aninterface.startIntent;

import java.util.ArrayList;
import java.util.Iterator;

public class AMainActivity extends AppCompatActivity {
    private TextView tv ;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_amain);
        tv = findViewById(R.id.tv);
        findViewById(R.id.A_btn).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                go();
//                load();
            }
        });

    }
    public void go(){
        spiFactory<startIntent> spiFactory = new spiFactory<>(startIntent.class);
        startIntent iPrint = spiFactory.getObject("goBImp");
        if(iPrint != null){
            iPrint.go("b");
        }
    }

    public void load() {
        spiFactory<startIntent> spiFactory = new spiFactory<>(startIntent.class);
        ArrayList<String> arrayList = spiFactory.getAllClassName();
        for(String name:arrayList){
            tv.append(name + "\n");
        }
    }
}